<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var sortPeople = function (names, heights) {
      return heights.map((h, i) => [h, names[i]]).sort((a, b) => b[0] - a[0]).map(a => a[1])
    };
    console.log(sortPeople(names = ["Mary", "John", "Emma"], heights = [180, 165, 170]))
  </script>
</body>

</html>